home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / giochi / aboulder.lha / ABoulderDash1.0 / extgfx.s < prev    next >
Text File  |  1995-08-27  |  29KB  |  1,325 lines

  1.     opt    L+
  2.     opt    O2+
  3.     opt    OW-
  4.  
  5. *==========================================
  6. *
  7. * File:        ExtGfx.s
  8. * Version:     6
  9. * Revision:    0
  10. * Created:     ??/??/????
  11. * By:          FNC Slothouber
  12. * Last Update: 12-IV-1993
  13. * By:          FNC Slothouber
  14. *
  15. *==========================================
  16.  
  17.     XREF    _IntuitionBase
  18.     XREF    _GfxBase
  19.     XREF    _DOSBase
  20.  
  21.     XDEF    AllocRasters
  22.     XDEF    FreeRasters
  23.     XDEF    EG_AllocBitMap
  24.     XDEF    EG_FreeBitMap
  25.     XDEF    GetPicture
  26.     XDEF    ClearBitMap
  27.     XDEF    GetDisplay
  28.     XDEF    FreeDisplay
  29.     XDEF    CreatePort
  30.     XDEF    DeletePort
  31.     XDEF    CreateStdIO
  32.     XDEF    CreateExtIO
  33.     XDEF    DeleteStdIO
  34.     XDEF    DeleteExtIO
  35.  
  36.     incdir    "include:"
  37.     include    exec/types.i
  38.     include    exec/nodes.i
  39.     include    exec/lists.i
  40.     include    exec/io.i
  41.     include    exec/exec_lib.i
  42.     include    exec/libraries.i
  43.     include    exec/initializers.i
  44.     include    exec/resident.i
  45.     include    exec/memory.i
  46.     include    exec/alerts.i
  47.     include    graphics/graphics_lib.i
  48.     include    graphics/view.i        ; For GetDisplay.
  49.     include    hardware/custom.i    ; For BlitCopyMem.
  50.     include    libraries/dos_lib.i
  51.     include libraries/dos.i
  52.     include    extgfx.i
  53.  
  54. ***********  MACRO's  ************************
  55.  
  56. beginlnk macro
  57. count    set    0
  58.     endm
  59. long    macro
  60. count    set    count-4
  61. \1    equ    count
  62.     endm
  63. word    macro
  64. count    set    count-2
  65. \1    equ    count
  66.     endm
  67. sizze    macro
  68. \1    equ    count
  69.     endm
  70.  
  71. CALLSYS    macro        same as CALLEX
  72.     CALLLIB    _LVO\1
  73.     endm
  74.  
  75. CLEAR    macro        quick method to clear a register
  76.     MOVEQ #0,\1
  77.     endm
  78.  
  79. CALLEX    macro
  80.     move.l    a6,-(sp)
  81.     move.l    4,a6
  82.     jsr    _LVO\1(a6)
  83.     move.l    (sp)+,a6
  84.     endm
  85.  
  86. CALLGFX    macro
  87.     move.l    a6,-(sp)
  88.     move.l    _GfxBase,a6
  89.     jsr    _LVO\1(a6)
  90.     move.l    (sp)+,a6
  91.     endm
  92.  
  93. CALLDOSF macro
  94.     move.l    a6,-(sp)
  95.     move.l    _DOSBase,a6
  96.     jsr    _LVO\1(a6)
  97.     move.l    (sp)+,a6
  98.     endm
  99.  
  100. CALLINTF macro
  101.     move.l    a6,-(sp)
  102.     move.l    _IntuitionBase,a6
  103.     jsr    _LVO\1(a6)
  104.     move.l    (sp)+,a6
  105.     endm
  106.  
  107. ******* ExtGfx.s/AllocRasters ******************************************
  108. *
  109. *   NAME    
  110. *    AllocRasters -- Allocate a number of bitplanes (rasters).
  111. *   SYNOPSIS
  112. *    succes = AllocRasters(BitMap)
  113. *    d0              A0
  114. *    LONG AllocRaster(struct BitMap *)
  115. *   FUNCTION
  116. *    Allocate "depth" BitPlanes, using the size given in the
  117. *    bitmap structure.
  118. *   INPUTS
  119. *    BitMap - A pointer to a bitmap structure containing the magic
  120. *        numbers.
  121. *   RESULT
  122. *    The plane-pointers will point to the allocated bitplanes. A
  123. *    none zero value will be returned to indicate everything is OK.
  124. *    If the allocation of one of the bitplanes failed, the
  125. *    already allocated bitplanes will be deallocated, and the
  126. *    return value will be zero.
  127. *   EXAMPLE
  128. *
  129. *   NOTES
  130. *    Use this routine only if you supply your own bitmap structure,
  131. *    normaly EG_AllocBitMap performs this task for you.
  132. *   BUGS
  133. *    Only possible if the you request a depth of 8 bitplanes or more.
  134. *   SEE ALSO
  135. *    FreeRasters()
  136. ******************************************************************************
  137. *
  138. *
  139.  
  140. AlR_reg    reg    a2/a3/d2
  141.  
  142. AllocRasters
  143.     movem.l    AlR_reg,-(sp)
  144.  
  145.     move.l    a0,a2        ; Pointer to the head of the bitmap stucture.
  146.     move.l    a0,a3        ; Pointer to the bitplane pointers.
  147.  
  148.     adda.l    #bm_Planes,a3    ; Get the number of bitplanes the user wants.
  149.     moveq    #0,d2
  150.     move.b    bm_Depth(a2),d2
  151.     beq    .ll2        ; User don't want bitplanes !
  152.  
  153.     subq.w  #1,d2
  154. .ll1    moveq    #0,d0         ; Because of move.w
  155.     moveq    #0,d1
  156.     move.w  bm_BytesPerRow(a2),d0
  157.     lsl.w    #3,d0         ; Calc. number of pixels.
  158.     move.w  bm_Rows(a2),d1    ; Height.
  159.     CALLGFX AllocRaster    ; Try to allocate a bitplane.
  160.     move.l    d0,(a3)+
  161.     beq    .geterr        ; It failed.
  162.     dbra    d2,.ll1        ; Next bitplane.
  163.  
  164. .ll2    movem.l    (sp)+,AlR_reg
  165.     moveq   #-1,d0         ; Every thing OK.
  166.     rts
  167.  
  168. .geterr    move.l    a2,a0        ; An error occured
  169.     bsr    FreeRasters    ; Give back the allocated bitplanes.
  170.     movem.l    (sp)+,AlR_reg
  171.     clr.l    d0        ; ERROR!!
  172.     rts
  173.  
  174. ******* ExtGfx.s/FreeRasters ******************************************
  175. *
  176. *   NAME    
  177. *    FreeRasters -- Deallocate all bitplanes of a BitMap.
  178. *   SYNOPSIS
  179. *    FreeRasters(BitMap)
  180. *            A0
  181. *    void FreeRasters(struct BitMap *)
  182. *   FUNCTION
  183. *    Dealocate all bitplanes. Using the bitplane pointers given
  184. *    in the bitmap structure.
  185. *   INPUTS
  186. *    BitMap - A pointer to a bitmap structure
  187. *   RESULT
  188. *    None
  189. *   EXAMPLE
  190. *
  191. *   NOTES
  192. *    You can AllocRaster(NULL).
  193. *   BUGS
  194. *
  195. *   SEE ALSO
  196. *    AllocRasters()
  197. ******************************************************************************
  198. *
  199. *
  200.  
  201. FrR_r reg    a2/d2/a3
  202.  
  203. FreeRasters
  204.     move.l    a0,d0
  205.     beq.s    .exit
  206.     movem.l    FrR_r,-(sp)
  207.  
  208.     move.l    a0,a2
  209.     move.l    a0,a3
  210.     move.w  #7,d2        ; Try to deallocate all the 8 bitbplanes.
  211.     adda.l    #bm_Planes,a3
  212. .ll1    movea.l    (a3)+,a0    ; Raster Pointer
  213.     cmp.l    #0,a0        ; Is the bitplane home ?
  214.     beq.s    .ll2        ; No then don't deallocate it.
  215.     moveq    #0,d0
  216.     moveq    #0,d1
  217.     move.w  bm_BytesPerRow(a2),d0
  218.     lsl.w    #3,d0        ; Calc. display width in pix.
  219.     move.w  bm_Rows(a2),d1    ; Display height.
  220.     CALLGFX FreeRaster    ; Deallocate bitplane.
  221. .ll2    dbra    d2,.ll1
  222.  
  223.     movem.l    (sp)+,FrR_r
  224. .exit    rts
  225.  
  226. ******* ExtGfx.s/EG_AllocBitMap ******************************************
  227. *
  228. *   NAME    
  229. *    EG_AllocBitMap -- Allocate memory for a bitmap structure,
  230. *    initialize it, and allocate Rasters.
  231. *   SYNOPSIS
  232. *    BitMap,errorcode = EG_AllocBitMap(depth,width,height)
  233. *    d0     d1               d0   ,d1   ,d2
  234. *    struct BitMap *EG_AllocBitMap(ULONG,ULONG,ULONG)
  235. *   FUNCTION
  236. *    This function will allocate a bitmap structure, initialize
  237. *    it with the magic numbers and allocate the number of rasters
  238. *    you requested for.
  239. *   INPUTS
  240. *    Depth - Depth of the BitMap [0..8]
  241. *    Width - Width of the BitMap
  242. *    Height - Height of the BitMap
  243. *   RESULT
  244. *    A pointer to an initialized BitMap structure
  245. *    If there was an error, all the memory will be deallocated,
  246. *    and the function will return a NULL pointer and an error code.
  247. *
  248. *    ErrorCode:
  249. *    1 = No memory for a bitmap.
  250. *    2 = No memory for the rasters.
  251. *   EXAMPLE
  252. *
  253. *   NOTES
  254. *
  255. *   BUGS
  256. *
  257. *   SEE ALSO
  258. *    EG_FreeBitMap()
  259. ******************************************************************************
  260. *
  261. *
  262.  
  263.  
  264. EG_AllocBitMap
  265.     move.l    d7,-(sp)
  266.  
  267.     movem.l    d0/d1,-(sp)
  268.     move.l    #bm_SIZEOF,d0    ; Alloc. mem. for bitmap.
  269.     move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  270.     CALLEX    AllocMem
  271.     tst.l    d0
  272.     bne.s    .ll1
  273.     movem.l    (sp)+,d0/d1
  274.     moveq    #1,d7        ; Error code 1 no mem.
  275.     bra    .err1
  276.  
  277. .ll1    move.l    d0,a0        ; Init. bitmap.
  278.     movem.l    (sp)+,d0/d1
  279.     move.l    a0,-(sp)
  280.     CALLGFX InitBitMap
  281.  
  282.     move.l    (sp),a0        ; Alloc. bitplanes.
  283.     bsr    AllocRasters
  284.     tst.l    d0        ; No error?
  285.     bne    .ll2
  286.     moveq    #2,d7        ; Errorcode 2 no bitplane mem. 
  287.     bra    .err2
  288.  
  289. .ll2    move.l    (sp)+,d0    ; Pointer to the bitmap.
  290.     move.l    (sp)+,d7
  291.     rts
  292.  
  293. .err2    move.l    (sp)+,a1    ; Dealloc. bitmap.
  294.     move.l    #bm_SIZEOF,d0
  295.     CALLEX    FreeMem
  296. .err1    moveq    #0,d0        ; Something went wrong.
  297.     move.l    d7,d1        ; Error code in d2
  298.     move.l    (sp)+,d7
  299.     rts
  300.  
  301.  
  302. ******* ExtGfx.s/EG_FreeBitMap ******************************************
  303. *
  304. *   NAME    
  305. *    EG_FreeBitMap --Deallocate all the memory use by the bitmap.
  306. *   SYNOPSIS
  307. *    EG_FreeBitMap(BitMap)
  308. *           A0
  309. *    void EG_FreeBitMap(struct BitMap *)
  310. *   FUNCTION
  311. *    The function FreeRasters is used to deallocate the memory
  312. *    used by the bitplanes. Then the memory allocated to store the
  313. *    bitmap stucture is deallocted.
  314. *   INPUTS
  315. *    BitMap - A pointer to a BitMap structure
  316. *   RESULT
  317. *    None
  318. *   EXAMPLE
  319. *
  320. *   NOTES
  321. *    You can EG_FreeBitMap(NULL)
  322. *   BUGS
  323. *
  324. *   SEE ALSO
  325. *    FreeRasters(), EG_AllocBitMap()
  326. ******************************************************************************
  327. *
  328. *
  329.  
  330. EG_FreeBitMap
  331.     move.l    a0,d0
  332.     beq.s    .exit
  333.     move.l    a0,-(sp)
  334.     bsr    FreeRasters 
  335.     move.l    (sp)+,a1 
  336.     move.l    #bm_SIZEOF,d0
  337.     CALLEX    FreeMem
  338. .exit    rts
  339.  
  340.  
  341. ******* ExtGfx.s/GetPicture ******************************************
  342. *
  343. *   NAME    
  344. *    GetPicture -- Load an IFF picture file from disk
  345. *   SYNOPSIS
  346. *    error = GetPicture(filename,BitMap,Colors)
  347. *    D0           A0        A1     A2
  348. *    ULONG GetPicture(STRPTR,struct BitMap *,UWORD *)
  349. *   FUNCTION
  350. *    The file is loaded into memory. If Colors <> NULL the
  351. *    colors of the picture are placed in the array Colors is pointing
  352. *    to. If the size of the picture is unequal to the size of the
  353. *    bitmap the picture will be clipped.
  354. *   INPUTS
  355. *    filename - A null terminated string.
  356. *    BitMap - A pointer to a BitMap structure.
  357. *    Colors - A pointer to a Array of at least 32 Words, to store the
  358. *       Colors
  359. *   RESULT
  360. *    Error:
  361. *    0 = OK
  362. *    1 = File Not Found
  363. *    2 = Out Of Memory
  364. *    3 = Read Error (I/O error)  Use IOerr for more information.
  365. *    4 = Not a IFF File
  366. *    5 = Bad Unpack
  367. *    6 = No BMHD
  368. *    7 = No BODY
  369. *    8 = No CMAP
  370. *    9 = Bad CMAP ( To many colors )
  371. *    10 = Compression method not supported.
  372. *   EXAMPLE
  373. *
  374. *   NOTES
  375. *    A bitmap with a depth of 0 can be used to extract the colors
  376. *    of picture.
  377. *   BUGS
  378. *    The routine can only handle packed pictures. (using the
  379. *    byte-run algorithm.), and plain (unpacked) pictures, all
  380. *    other compression methods are not supported. Howerever at
  381. *    this writing byte-run is the only compression method used.
  382. *   SEE ALSO
  383. *
  384. ******************************************************************************
  385. *
  386. *
  387.  
  388.     beginlnk
  389.     long    GP_filename
  390.     long    GP_filehd
  391.     long    GP_mem1
  392.     long    GP_mem2
  393.     long    GP_mem3
  394.     long    GP_sizemem2
  395.     word    GP_depth    ; Number of bitplanes needed.
  396.     word    GP_width    ; Width of the picture
  397.     word    GP_height    ; Height of the picture
  398.     word    GP_compr    ; type of compression
  399.     long    GP_nr_packed    ; Nuber of bytes that form the picture.
  400.     long    GP_bitmap    ; User supplied bitmap
  401.     sizze    GP_sizeof
  402.  
  403. GP_regs    reg    d2-d7/a2-a6
  404.  
  405. GetPicture
  406.     movem.l    GP_regs,-(sp)
  407.     link    a5,#GP_sizeof
  408.     move.l    a0,GP_filename(a5)
  409.     move.l    a1,GP_bitmap(a5)
  410.     moveq    #0,d0
  411.     move.l    d0,GP_mem1(a5)    ; So error knows what is allocated
  412.     move.l    d0,GP_mem2(a5)    ; and what's not.
  413.     move.l    d0,GP_mem3(a5)
  414.     move.l    d0,GP_filehd(a5)
  415.  
  416.     move.l    a0,d1        ; Open the file.
  417.     move.l    #MODE_OLDFILE,d2
  418.     CALLDOSF Open
  419.     move.l    d0,GP_filehd(a5)
  420.     bne.s .ll1
  421.     moveq    #1,d7
  422.     bra    GP_error    ; Open failed !
  423. .ll1
  424.     moveq    #8,d0         ; Allocate public mem.
  425.     move.l    #1,d1        ; 8 bytes
  426.     CALLEX  AllocMem
  427.     move.l    d0,GP_mem1(a5)
  428.     bne.s    .ll2
  429.     moveq    #2,d7
  430.     bra    GP_error
  431. .ll2
  432.     move.l    GP_filehd(a5),d1    ; Read the first 8
  433.     move.l    GP_mem1(a5),d2        ; bytes.
  434.     moveq    #8,d3
  435.     CALLDOSF Read
  436.     bpl.s     .ll3
  437.     moveq    #3,d7
  438.     bra    GP_error        ; IOerr
  439. .ll3
  440.     move.l    GP_mem1(a5),a0        ; Is it a FORM file.
  441.     cmp.l    #"FORM",(a0)
  442.     beq    .ll4
  443.     moveq    #4,d7
  444.     bra    GP_error        ; No
  445. .ll4
  446.     move.l    4(a0),GP_sizemem2(a5)    ; Size of the IFF file.
  447.  
  448.     move.l    4(a0),d0        ; Alloceer public mem.
  449.     move.l    #1,d1
  450.     CALLEX  AllocMem
  451.     move.l    d0,GP_mem2(a5)
  452.     bne.s     .ll5
  453.     moveq     #5,d7
  454.     bra    GP_error
  455. .ll5
  456.     move.l    GP_sizemem2(a5),d3    ; Load file.
  457.     move.l    GP_filehd(a5),d1
  458.     move.l    GP_mem2(a5),d2
  459.     CALLDOSF Read
  460.     cmp.l    #-1,d0
  461.     bne.s     .ll6
  462.     moveq    #3,d7
  463.     bra    GP_error
  464. .ll6
  465.     move.l    #8*4,d0            ; Public mem for bitplane
  466.     move.l    #1,d1            ; pointers.
  467.     CALLEX  AllocMem
  468.     move.l    d0,GP_mem3(a5)
  469.     bne    .ll7
  470.     moveq     #6,d7
  471.     bra    GP_error
  472.  
  473. ** Copy bitplane pointers
  474.  
  475. .ll7
  476.     moveq    #7,d0
  477.     move.l    GP_bitmap(a5),a0
  478.     adda.l    #bm_Planes,a0
  479.     move.l    GP_mem3(a5),a1
  480. .ll8
  481.     move.l    (a0)+,(a1)+
  482.     dbra    d0,.ll8
  483.  
  484.     cmp.l    #0,a2            ; Does the user wants colors ?
  485.     beq    .geencol
  486.  
  487. ** Find color header "CMAP"
  488.  
  489.     move.l    GP_mem2(a5),a0
  490.     clr.l    d0
  491. .col0    addq.l    #1,d0
  492.     cmp.l    GP_sizemem2(a5),d0    ; End of file ?
  493.     bne.s    .col1
  494.     moveq    #8,d7            ; Yes error #8, no CMAP
  495.     bra    GP_error
  496. .col1
  497.     cmp.b    #'C',(a0)+
  498.     bne.s    .col0
  499.     cmp.b    #'M',(a0)
  500.     bne.s    .col0
  501.     cmp.b    #'A',1(a0)
  502.     bne.s    .col0
  503.     cmp.b    #'P',2(a0)
  504.     bne.s    .col0
  505.  
  506.     clr.l    d1
  507.     clr.l    d2
  508.     adda.l    #3,a0
  509.     move.l    (a0)+,d0    ; Number of entries
  510.     cmp.l    #3*32,d0
  511.     bls.s    .col2
  512.     moveq    #9,d7        ; Get colors error.
  513.     bra    GP_error
  514. .col2
  515.     move.b    (a0)+,d1    ; Assemble colors
  516.     lsl.l    #4,d1        ; and put them in an array.
  517.     or.b    (a0)+,d1
  518.     move.b    (a0)+,d2
  519.     lsr.b    #4,d2
  520.     or.b    d2,d1
  521.     move.w    d1,(a2)+
  522.     subq.w    #3,d0
  523.     bpl.s    .col3
  524.     moveq    #9,d7        ; Get colors error.
  525.     bra    GP_error
  526. .col3    bne.s    .col2
  527.  
  528. .geencol
  529.  
  530. ** format of the picture.
  531. ** find "BMHD"
  532.  
  533.     move.l    GP_mem2(a5),a0
  534.     clr.l    d0
  535. .bmh0    addq.l    #1,d0
  536.     cmp.l    GP_sizemem2(a5),d0    ; End of file ?
  537.     bne.s    .bmh1
  538.     moveq    #6,d7            ; Yes error #6, no BMHD
  539.     bra    GP_error
  540. .bmh1
  541.     cmp.b    #'B',(a0)+
  542.     bne.s    .bmh0
  543.     cmp.b    #'M',(a0)
  544.     bne.s    .bmh0
  545.     cmp.b    #'H',1(a0)
  546.     bne.s    .bmh0
  547.     cmp.b    #'D',2(a0)
  548.     bne.s    .bmh0
  549.     adda.l    #3+4,a0
  550.  
  551.     move.w    (a0)+,GP_width(a5)    ; Found width.
  552.     move.w    (a0)+,GP_height(a5)    ; Found height
  553.     addq.l    #4,a0             ; SKIP x and y position.
  554.     move.b    (a0)+,GP_depth(a5)    ; Found depth
  555.     addq.l    #1,a0            ; SKIP masking
  556.     move.b    (a0)+,d0
  557.     move.b    d0,GP_compr(A5)        ; Type of compression
  558.     cmp.b    #2,d0            ; Compression type supported ?
  559.     blt.s    .bmh2
  560.     moveq    #10,d7
  561.     bra    GP_error        ; Compression type not supported
  562. .bmh2
  563.     
  564.  
  565. ** Find body
  566.  
  567.     move.l    GP_mem2(a5),a0
  568.     moveq    #0,d0
  569. .bod0    addq.l    #1,d0
  570.     cmp.l    GP_sizemem2(a5),d0    ; End of file ?
  571.     bne.s    .bod1
  572.     moveq    #7,d7            ; Yes error #7, no BODY
  573.     bra    GP_error
  574. .bod1    cmp.b    #'B',(a0)+
  575.     bne.s    .bod0
  576.     cmp.b    #'O',(a0)
  577.     bne.s    .bod0
  578.     cmp.b    #'D',1(a0)
  579.     bne.s    .bod0
  580.     cmp.b    #'Y',2(a0)
  581.     bne.s    .bod0
  582.     adda.l    #3,a0
  583.  
  584.     move.l    (a0)+,GP_nr_packed(a5) ; Number of bytes in body.
  585.  
  586.  
  587. ** Restore picture
  588.  
  589. .unp    moveq    #0,d3
  590.     move.w    GP_width(a5),d3        ; Width pic. in bytes.
  591.     lsr.l    #3,d3
  592.     move.l    GP_bitmap(a5),a1
  593.     moveq    #0,d4
  594.     move.w    bm_BytesPerRow(a1),d4    ; Width BitMap in bytes.
  595.     move.l    d4,d5
  596.     sub.l    d3,d5            ; modulo = W_BM - W_pic.
  597.  
  598.     move.l    GP_bitmap(a5),a1    ; Number of lines.
  599.     clr.l    d7
  600.     move.w    bm_Rows(a1),d7
  601.     cmp.w    GP_height(a5),d7    ; H_pic. < H_bm ?
  602.     bls    .unp0
  603.     move.w    GP_height(a5),d7    ; Yes use height pic.
  604. .unp0    subq.w    #1,d7
  605.     
  606. .unp3    move.l    GP_mem3(a5),a2
  607.  
  608.     clr.w    d6
  609.     move.b    GP_depth(a5),d6        ; Number of bitplanes
  610.     subq.w    #1,d6
  611.  
  612. .unp2    move.l    (a2)+,a1
  613.     tst.b    GP_compr(a5)        ; Compression used ?
  614.     bne.s    .unp5            
  615.     bsr    restoreline        ; No just copy line
  616.     bra.s    .unp4            ; No error possible !
  617. .unp5    bsr    unpackaline
  618.     tst.l    d0            ; Error while unpacking ?
  619.     bne    .unp4
  620.     moveq    #5,d7            ; Yes error #5 bad unpack 
  621.     bra    GP_error
  622. .unp4    move.l    a1,-4(a2)
  623.  
  624.     dbra    d6,.unp2        ; Next bitplane.
  625.     
  626.     dbra    d7,.unp3        ; Next line.
  627.  
  628. GP_exit
  629.     clr.l d7             ; No errors.
  630. GP_error
  631.     move.l    GP_filehd(a5),d1
  632.     beq    .ll1
  633.     CALLDOSF Close
  634. .ll1
  635.     move.l    GP_mem1(a5),d1
  636.     beq    .ll2
  637.     move.l    d1,a1
  638.     moveq #8,d0
  639.     CALLEX FreeMem
  640. .ll2
  641.     move.l    GP_mem2(a5),d1
  642.     beq    .ll3
  643.     move.l    d1,a1
  644.     move.l    GP_sizemem2(a5),d0
  645.     CALLEX FreeMem
  646. .ll3
  647.     move.l    GP_mem3(a5),d1
  648.     beq    .ll4
  649.     move.l    d1,a1
  650.     move.l    #8*4,d0
  651.     CALLEX FreeMem
  652. .ll4
  653.     move.l    d7,d0
  654.     unlk    a5
  655.     movem.l    (sp)+,GP_regs
  656.     rts
  657.  
  658. restoreline    ; (source,dest,widthpic/8,widthbm/8),a0,a1,d3,d4
  659.  
  660.     suba.l    a3,a3        ; Make a NULL
  661.     cmp.l    a3,a1        ; Bitplane Home ?
  662.     beq.s    .res1
  663.     
  664.     move.l    a0,a3
  665.     move.l    a1,a4
  666.     cmp.w    d4,d3
  667.     bls.s    .res3        ; pic <= bitmap
  668.     move.w    d4,d0        ; no width = width bitmap
  669.     bra.s    .res4
  670. .res3    move.w    d3,d0        ; yes width = width pic
  671.  
  672. .res4    subq.w    #1,d0
  673. .res2    move.b    (a3)+,(a4)+    ; copy line pic to line bitmap
  674.     dbra    d0,.res2
  675.     add.l    d4,a1        ; next line in bitmap
  676.  
  677. .res1    add.l    d3,a0        ; next line in pic    
  678.     moveq    #-1,d0        ; all OK
  679.     rts    
  680.  
  681. unpackaline    ; (source,dest,widthpic/8,widthbm/8),a0,a1,d3,d4
  682.  
  683. *!!!!! Internal Routine !!!!
  684.  
  685.     suba.l    a3,a3        ; Make a NULL
  686.     clr.w    d0        ; nr = 0
  687. un1
  688.     clr.w    d1
  689.     move.b    (a0)+,d1
  690.     cmp.b    #128,d1        ; NOP
  691.     beq    npover
  692.     tst.b    d1
  693.     bpl.s    plus
  694.  
  695.     move.b (a0)+,d2
  696.     neg.b   d1
  697.  
  698. ** Herhaal volgende byte (-n)+1 maal
  699. un2    cmp.l    a3,a1        ; Bitplane home ?
  700.     beq.s    .ll1        ; No, don't dump bytes.
  701.     cmp.w    d4,d0
  702.     bhs.s    .ll1        ; bm line full, don't dump bytes
  703.  
  704.     move.b    d2,(a1)+    
  705. .ll1    addq.w  #1,d0        ; nr=nr+1
  706.     cmp.w    d3,d0
  707.     bhi.s    UpL_error    ; UnPack error to many bytes in one line!
  708.     dbf    d1,un2
  709.     bra.s    npover
  710.  
  711. **  copieer (n)+1 bytes
  712. plus    move.b    (a0)+,d2
  713.  
  714.     cmp.l    a3,a1        ; Bitplane home ?
  715.     beq.s    .ll1        ; No, don't dump bytes.
  716.     cmp.w    d4,d0
  717.     bhs.s    .ll1        ; bm line full, don't dump bytes
  718.  
  719.     move.b    d2,(a1)+ 
  720. .ll1    addq.w  #1,d0        ; nr=nr+1
  721.     cmp.w    d3,d0
  722.     bhi.s    UpL_error    ; Unpack Error to many bytes in one line!
  723.     dbf    d1,plus
  724. npover
  725.     cmp.w   d3,d0
  726.     bne.s    un1
  727.  
  728.     cmp.l    a3,a1        ; Bitplane Home ?
  729.     beq.s    .ll1        ; No, then we don't need a modulo.
  730.     tst.l    d5        ; Do we really need a modulo?
  731.     bmi.s    .ll1
  732.     adda.l    d5,a1        ; Yes, wilst bitmap larger then piciture.
  733.  
  734. .ll1    moveq    #-1,d0        ; No error.
  735.     rts
  736. UpL_error
  737.     moveq    #0,d0        ; Panic an error !!
  738.     rts
  739.  
  740. ******* ExtGfx.s/ClearBitMap ******************************************
  741. *
  742. *   NAME    
  743. *    ClearBitMap -- Clear all bitplanes
  744. *   SYNOPSIS
  745. *    ClearBitMap(BitMap)
  746. *            A0
  747. *    void ClearBitMap(struct BitMap *)
  748. *   FUNCTION
  749. *    Clear all bitplanes defined in the bitmap using the blitter.
  750. *   INPUTS
  751. *    BitMap - A pointer to a bitmap structure.
  752. *   RESULT
  753. *
  754. *   EXAMPLE
  755. *
  756. *   NOTES
  757. *
  758. *   BUGS
  759. *    Possible because of a bug in the blitter.
  760. *   SEE ALSO
  761. *
  762. ******************************************************************************
  763. *
  764. *
  765.  
  766. ClearBitMap
  767.     movem.l    a2/a3,-(sp)
  768.  
  769.     move.l    a0,a3
  770.     move.w    bm_BytesPerRow(a3),d0
  771.     lsr.w    #1,d0            ; Number of words
  772.     move.w    bm_Rows(a3),d1
  773.     lsl.w    #6,d1
  774.     or.w    d0,d1            ; Calc size of blit.
  775.  
  776.     clr.w    d0
  777.     move.b    bm_Depth(a3),d0
  778.     subq.w    #1,d0            ; Number of blits.
  779.     adda.l    #8,a3            ; Pointer to bitplane pointers
  780.  
  781.     move.l    #$dff000,a2        ; Custom Chip base addr.
  782.  
  783.     CALLGFX WaitBlit
  784.     CALLGFX OwnBlitter
  785. ** Falid for every blit.
  786.     move.w    #0,bltdmod(a2)        ; Mod D = 0
  787.     move.w    #$01f0,bltcon0(a2)    ; Use D , D=A
  788.     move.w    #$0000,bltcon1(a2)    ; no shift etc
  789.     move.w    #$ffff,bltafwm(a2)    ; ?
  790.     move.w    #$ffff,bltalwm(a2)    ; ?
  791.     move.w    #$0000,bltadat(a2)    ; 0 -> DEST
  792. .ll1
  793.     move.l    (a3)+,bltdpt(a2)    ; Clear bitplane.
  794.     move.w    d1,bltsize(a2)        ; Start  blitter
  795.     CALLGFX WaitBlit        ; Blitter finished ?
  796.     dbra    d0,.ll1            ; Next bitplane
  797.  
  798.     CALLGFX DisownBlitter
  799.     CALLGFX WaitBlit        ; ???
  800.     movem.l    (sp)+,a2/a3
  801.     rts
  802.  
  803.  
  804. ******* ExtGfx.s/GetDisplay ******************************************
  805. *
  806. *   NAME    
  807. *    GetDisplay - Allocate and initialize a display structure.
  808. *   SYNOPSIS
  809. *    display, error code =
  810. *    D0     D1    
  811. *        GetDisplay(new_Display,BitMap1,BitMap2)
  812. *               A2          A0      [A1]
  813. *    struct Display *GetDisplay(struct new_Display *,
  814. *        struct BitMap *,struct BitMap *)
  815. *   FUNCTION
  816. *    Allocate and initialize a Display Structure
  817. *    - Allocate memory for a display structure.
  818. *    - Allocate a colormap.
  819. *    - Initialize a rasinfo.
  820. *    - Initialize a Viewport.
  821. *    - Initialize a View.
  822. *    - Link the bitmap, rasinfo, viewport and view together.
  823. *    if DUALPFIELD then
  824. *        Allocate a second RastInfo.
  825. *        Link second RasInfo to first RasInfo.
  826. *        Initialize the second RasInfo.
  827. *        Link second Bitmap to second RasInfo.
  828. *
  829. *    If an error occurs all memory allocated will be deallocated.
  830. *
  831. *   INPUTS
  832. *    new_Display - A pointer to a new Display structure
  833. *        Defining: The width (in pixels) of the display. If the size
  834. *            is equal to -1, the width of the bitmap will be used.
  835. *        The height (in pixels) of the display. If the height
  836. *            is equal to -1, the height of the bitmap will be used.
  837. *        The display mode (V_HAM, V_HIRES, V_DUALPLFLD, V_LACE).
  838. *    BitMap1 - A pointer to a initialized bitmap structure.
  839. *    BitMap2 - A pointer to a initialized BitMap structure. (Only
  840. *       needed if you request DUALPLAYFIELD).
  841. *
  842. *   RESULT
  843. *    A pointer to a display structure which contains a pointer to
  844. *    a view, a viewport and a rasinfo structure. All you need to
  845. *    create a display now, is a call to makevport, mrgcopper and
  846. *    loadview.
  847. *
  848. *    If there was an error:
  849. *    A Nill pointer and a error code.
  850. *    1 = No memory for the display structure.
  851. *    2 = GetColorMap failed. 
  852. *    3 = No memory for extra RasInfo structure.
  853. *
  854. *   EXAMPLE
  855. *
  856. *    ...
  857. *    move.l    my_bitmap,a0
  858. *    sub.l    a1,a1            ; only one bitmap
  859. *    lea    new_display,a2
  860. *    CALLEXT    GetDisplay
  861. *    move.l    d0,display
  862. *    beq     error
  863. *
  864. *    move.l    display,a2
  865. *    move.l    dsp_View(a2),a0        ; Get the allocated view
  866. *    move.l    dsp_ViewPort(a2),a1    ; Get the allocated viewport
  867. *    CALLGRAF MakeVPort
  868. *    move.l    dsp_View(a2),a1
  869. *    CALLGRAF MrgCop            ; Mrg all copper list
  870. *    move.l    dsp_View(a2),a1
  871. *    CALLGRAF LoadView        ; Show the display
  872. *    ...
  873. *
  874. * new_display
  875. *    dc.w    -1            ; USE THE SIZE GIVEN IN THE BITMAP
  876. *    dc.w    -1,d1            ; USE THE SIZE GIVEN IN THE BITMAP.
  877. *    dc.w    V_HAM            ; A HOLD AND MODIFY DISPLAY
  878. *
  879. *    The display structure can be found in the file extgfx.i
  880. *   NOTES
  881. *
  882. *   BUGS
  883. *
  884. *   SEE ALSO
  885. *    FreeDisplay()
  886. ******************************************************************************
  887. *
  888. *
  889.  
  890.     beginlnk
  891.     long    gdp_BM1
  892.     long    gdp_BM2
  893.     long    gdp_ColorMap
  894.     long    gdp_dsp
  895.     word    gdp_Width
  896.     word    gdp_Height
  897.     word    gdp_Modes
  898.     sizze    gdp_sizeof
  899.  
  900. GDP_regs    reg    a2/d7
  901. GetDisplay
  902.     movem.l    GDP_regs,-(sp)
  903.  
  904.     link    a5,#gdp_sizeof
  905.  
  906.     clr.l    gdp_ColorMap(a5)
  907.     move.w    new_dsp_width(a2),gdp_Width(a5)
  908.     move.w    new_dsp_height(a2),gdp_Height(a5)
  909.     move.w    new_dsp_modes(a2),gdp_Modes(a5)
  910.     move.l    a0,gdp_BM1(a5)
  911.     move.l    a1,gdp_BM2(a5)
  912.  
  913.     lea    dsp_Template(pc),a0    ; Allocate memory for a view, 
  914.     CALLEX    AllocEntry        ; a viewport and a rasinfo structure
  915.     move.l    d0,gdp_dsp(a5)
  916.     bpl.s    .ll1
  917.     moveq.l    #1,d7
  918.     beq    gdp_error
  919.  
  920. .ll1    moveq.l    #32,d0            ; Make a colormap.
  921.     CALLGFX    GetColorMap
  922.     move.l    d0,gdp_ColorMap(a5)
  923.     bne.s    .ll2
  924.     moveq.l    #2,d7
  925.     beq    gdp_error
  926.  
  927. .ll2    move.l    gdp_BM1(a5),a0        ; Use bitmap format or use user
  928.     tst.w    gdp_Width(a5)        ; supplied format ?
  929.     bpl.s    .ll3
  930.     move.w    bm_BytesPerRow(a0),d0    ; Use bytesperrow to calculate
  931.     lsl.w    #3,d0            ; the width of the display
  932.     move.w    d0,gdp_Width(a5)
  933.  
  934. .ll3    tst.w    gdp_Height(a5)
  935.     bpl.s    .ll4
  936.     move.w    bm_Rows(a0),gdp_Height(a5)
  937.  
  938. .ll4    move.l    gdp_dsp(a5),a2
  939.     move.l    dsp_ViewPort(a2),a0
  940.     CALLGFX InitVPort
  941.     move.l    dsp_ViewPort(a2),a1
  942.     move.l    dsp_RasInfo(a2),vp_RasInfo(a1)        ; Link RI - VP
  943.     move.l    gdp_ColorMap(a5),vp_ColorMap(a1)    ; Link CM - VP
  944.     move.w    gdp_Width(a5),vp_DWidth(a1)        ; Set Width
  945.     move.w    gdp_Height(a5),vp_DHeight(a1)        ; and height VP
  946.     move.w    gdp_Modes(a5),vp_Modes(a1)        ; Set DispMode
  947.  
  948.     move.l    dsp_View(a2),a1
  949.     CALLGFX    InitView
  950.     move.l    dsp_View(a2),a1
  951.     move.l    dsp_ViewPort(a2),v_ViewPort(a1)        ; LINK VP - V
  952.     move.w    gdp_Modes(a5),v_Modes(a1)
  953.  
  954.     move.l    dsp_RasInfo(a2),a1            ; LINK BM - RI
  955.     move.l    gdp_BM1(a5),ri_BitMap(a1)
  956.  
  957.     andi.w    #V_DUALPF,gdp_Modes(a5)
  958.     beq    .ll5
  959. ** Dualplay field , we need an extra Bitmap and RasInfo.
  960.     move.l    #ri_SIZEOF,d0
  961.     move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1
  962.     CALLEX    AllocMem
  963.     move.l    gdp_dsp(a5),a1
  964.     move.l    dsp_RasInfo(a1),a1
  965.     move.l    d0,ri_Next(a1)        ; Link RasInfo1 with RasInfo2 
  966.     bne    .ll6
  967.     moveq.l    #3,d7
  968.     bra    gdp_error
  969. .ll6    move.l    d0,a0
  970.     move.l    gdp_BM2(a5),ri_BitMap(a0)    ; Link Bitmap2 with RasInfo2
  971.  
  972. .ll5    move.l    gdp_dsp(a5),d0    ; Return a pointer to the display struct. 
  973.     unlk    a5
  974.     movem.l    (sp)+,GDP_regs
  975.     rts
  976.  
  977. gdp_error            ; Deallocate the allocated.
  978.     move.l    gdp_ColorMap(a5),d0
  979.     beq    .ll1
  980.     move.l    d0,a0
  981.     CALLGFX    FreeColorMap
  982. .ll1    move.l    gdp_dsp(a5),d0
  983.     beq    .ll2
  984.     move.l    d0,a0
  985.     move.l    a0,-(sp)
  986.     move.l    dsp_RasInfo(a0),a0    ; Do we have an extra RasInfo?
  987.     move.l    ri_Next(a0),d0
  988.     beq    .ll1_1
  989.     move.l    d0,a1
  990.     move.l    #ri_SIZEOF,d0
  991.     CALLEX    FreeMem
  992. .ll1_1    move.l    (sp)+,a0
  993.     CALLEX    FreeEntry
  994. .ll2    clr.l    d0        ; There was an error.
  995.     move.l    d7,d1        ; Error code.
  996.     unlk    a5
  997.     movem.l    (sp)+,GDP_regs
  998.     rts
  999.  
  1000. ******* ExtGfx.s/FreeDisplay ******************************************
  1001. *
  1002. *   NAME    
  1003. *    FreeDisplay -- Dealocate the memory allocated by GetDisplay.
  1004. *   SYNOPSIS
  1005. *    FreeDisplay(Display)
  1006. *            A0
  1007. *    void FreeDisplay(struct Display *)
  1008. *   FUNCTION
  1009. *    Deallocate the colormap.
  1010. *    Deallocate the memory for the display structure.
  1011. *    If there is an extra RasInfo then deallocate it.
  1012. *   INPUTS
  1013. *    Display - A pointer to a Display structure.
  1014. *   RESULT
  1015. *
  1016. *   EXAMPLE
  1017. *
  1018. *   NOTES
  1019. *    You can FreeDisplay(NULL) !
  1020. *   BUGS
  1021. *
  1022. *   SEE ALSO
  1023. *    GetDisplay()
  1024. ******************************************************************************
  1025. *
  1026. *
  1027.  
  1028. FreeDisplay
  1029.     move.l    a0,d0
  1030.     beq.s    .exit
  1031.     move.l    a0,-(sp)
  1032.     move.l    dsp_RasInfo(a0),a0    ; Do we have an extra RasInfo?
  1033.     move.l    ri_Next(a0),d0
  1034.     beq    .ll1
  1035.     move.l    d0,a1
  1036.     move.l    #ri_SIZEOF,d0
  1037.     CALLEX    FreeMem
  1038. .ll1    move.l    (sp),a0
  1039.     move.l    dsp_ViewPort(a0),a0
  1040.     move.l    vp_ColorMap(a0),a0
  1041.     CALLGFX    FreeColorMap
  1042.     move.l    (sp)+,a0
  1043.     CALLEX    FreeEntry
  1044. .exit    rts
  1045.  
  1046.  
  1047. ******* ExtGfx.s/CreatePort ******************************************
  1048. *
  1049. *   NAME    
  1050. *    CreatePort -- Create a MessagePort.
  1051. *   SYNOPSIS
  1052. *    MsgPort=CreatePort(Name,Priority)
  1053. *    D0                 A0   D0
  1054. *    struct MsgPort *CreatePort(STRPTR *,INT)
  1055. *   FUNCTION
  1056. *    Allocates a SignalBit and memory for a MsgPort structure
  1057. *    and initializes the structure.
  1058. *   INPUTS
  1059. *    Name -  A null terminated string.
  1060. *    Priority - The priority for the port to be created.
  1061. *   RESULTS
  1062. *    A pointer to a to the Message Port.
  1063. *    A NULL pointer in case of an error.
  1064. *    If you supplied a name the port will be made public using the
  1065. *    funtion AddPort.
  1066. *   BUGS
  1067. *    ?
  1068. *   SEE ALSO
  1069. *    DeletePort
  1070. ******************************************************************************
  1071. *
  1072. *
  1073.  
  1074. CreatePort    ; (Name,Priority),A0,D0 -> (MsgPort),D0
  1075.  
  1076.     move.l    a2,-(sp)
  1077.  
  1078.     movem.l    a0/d0,-(sp)        ; Save name & pri
  1079.  
  1080.     move.l    #MP_SIZE,d0        ; Alloc mem for msg-port.
  1081.     move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1
  1082.     CALLEX    AllocMem
  1083.     move.l    d0,a2
  1084.     tst.l    d0
  1085.     beq    .err1            ; Alloc mem failed
  1086.  
  1087.     moveq.l    #-1,d0            ; Alloc signal for msg-port.
  1088.     CALLEX    AllocSignal
  1089.     move.b    d0,MP_SIGBIT(a2)    
  1090.     beq    .err2            ; All signals in use.
  1091.  
  1092.     movem.l    (sp)+,a0/d0        ; restore name & pri
  1093.     move.l    a0,LN_NAME(a2)        ; link name to msgport
  1094.     move.b    d0,LN_PRI(a2)        ; set pri for msgport
  1095.     move.b    #PA_SIGNAL,MP_FLAGS(a2)
  1096.  
  1097.     suba.l    a1,a1            ; Find the Task that called
  1098.     CALLEX    FindTask        ; this function.
  1099.     move.l    d0,MP_SIGTASK(a2)
  1100.  
  1101.     move.b    #NT_MSGPORT,LN_TYPE(a2)
  1102.  
  1103.     tst.l    LN_NAME(a2)        ; test if the port has a name
  1104.     beq.s    .ll1    
  1105.     move.l    a2,a1
  1106.     CALLEX    AddPort            ; if so make the port public
  1107.     move.l    a2,d0            ; Point to the port in D0 (result)
  1108.     bra.s    .ll2
  1109.     
  1110. .ll1    move.l    a2,d0
  1111.     adda.l    #MP_MSGLIST,a2
  1112.     NEWLIST    a2
  1113.  
  1114. .ll2    move.l    (sp)+,a2
  1115.     rts
  1116. .err2
  1117.     move.l    a2,a1
  1118.     move.l    #MP_SIZE,d0
  1119.     CALLEX    FreeMem
  1120. .err1
  1121.     CLEAR    d0
  1122.     movem.l    (sp)+,a0/d0        remove name & pri from stack
  1123.     move.l    (sp)+,a2
  1124.     rts
  1125.  
  1126. ******* ExtGfx.s/DeletePort ******************************************
  1127. *
  1128. *   NAME    
  1129. *    DeletePort -- Free the memory and signal allocted
  1130. *              for a MessagePort.
  1131. *   SYNOPSIS
  1132. *    DeletePort(MsgPort)
  1133. *                 A0   
  1134. *    void DeletePort(struct MsgPort *)
  1135. *   FUNCTION
  1136. *    Free the memory allocated for the MsgPort Structure, and
  1137. *    free the SignalBit used by the message port. If the port has a 
  1138. *    name and therefore is public it will be removed using RemPort.
  1139. *   INPUTS
  1140. *    A pointer to a message port.
  1141. *   RESULTS
  1142. *    None.
  1143. *   BUGS
  1144. *    ?
  1145. *   SEE ALSO
  1146. *    CreatePort
  1147. *
  1148. ******************************************************************************
  1149. *
  1150. *
  1151.  
  1152. DeletePort    ; (MSGPort),a0
  1153.  
  1154.     tst.l    LN_NAME(a0)        test if the port has a name
  1155.     beq.s    .ll1            and therefore is public 
  1156.     move.l    a0,-(sp)
  1157.     move.l    a0,a1
  1158.     CALLEX    RemPort            remove the port from public use
  1159.     move.l    (sp)+,a0
  1160.     
  1161. .ll1    CLEAR    d0
  1162.     move.b    MP_SIGBIT(a0),d0
  1163.     CALLEX    FreeSignal        free signal bit
  1164.     move.l    a0,a1
  1165.     move.l    #MP_SIZE,d0        free memory allocted for port
  1166.     CALLEX    FreeMem
  1167.  
  1168.     rts
  1169.  
  1170. ******* ExtGfx.s/CreateStdIO ******************************************
  1171. *
  1172. *   NAME    
  1173. *    CreatePort -- Create a MessagePort.
  1174. *   SYNOPSIS
  1175. *    StdIO=CreateStdIO(MsgPort)
  1176. *    d0            a0
  1177. *    struct IORequest *CreateStdIO(MsgPort *)
  1178. *   FUNCTION
  1179. *    Allocates memory for a IORequest structure and initializes the
  1180. *    structure.
  1181. *   INPUTS
  1182. *    MsgPort - A pointer to an already initialized message port to
  1183. *          be used for this I/O request's reply port.
  1184. *   RESULTS
  1185. *    Returns a pointer to the new I/O Request block, or NULL if.
  1186. *    the request failed.
  1187. *   BUGS
  1188. *    ?
  1189. *   SEE ALSO
  1190. *    CreateExtIO, DeleteStdIO
  1191. ******************************************************************************
  1192. *
  1193. *
  1194.  
  1195. CreateStdIO    ; (MsgPort),a0
  1196.  
  1197.     move.l    #IOSTD_SIZE,d0
  1198.     jsr    CreateExtIO
  1199.     rts
  1200.  
  1201.  
  1202. ******* ExtGfx.s/CreateExtIO ******************************************
  1203. *
  1204. *   NAME
  1205. *    CreateExtIO -- Create an I/O request.
  1206. *   SYNOPSIS
  1207. *    ExtIO=CreateExtIO(MsgPort,Size)
  1208. *    d0          a0      d0
  1209. *    struct IORequest *CreateExtIO(struct MsgPort *,INT)
  1210. *   FUNCTION
  1211. *    Allocates memory for and initializes a new I/O request block
  1212. *    of a user-specified number of bytes. The number of bytes MUST
  1213. *    be greater than the length of a Exec message, or some very nasty
  1214. *    things will happen.
  1215. *    structure.
  1216. *   INPUTS
  1217. *    MsgPort - A pointer to an already initialized message port to
  1218. *          be used for this I/O request's reply port.
  1219. *    size    - the size of the I/O request to be created.
  1220. *   RESULTS
  1221. *    Returns a pointer to the new I/O Request block, or NULL if.
  1222. *    the request failed.
  1223. *   BUGS
  1224. *    ?
  1225. *   SEE ALSO
  1226. *    DeleteExtIO
  1227. ******************************************************************************
  1228. *
  1229. *
  1230.  
  1231. CreateExtIO    ; (Size,MsgPort),d0,a0 -> (IOReq),d0
  1232.  
  1233.     move.w    d0,-(sp)
  1234.     move.l    a0,-(sp)
  1235.  
  1236.     move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1
  1237.     CALLEX    AllocMem
  1238.     tst.l    d0
  1239.     beq    .err
  1240.     move.l    d0,a1
  1241.  
  1242.     move.b    #NT_MESSAGE,LN_TYPE(a1)
  1243.     move.l    (sp)+,MN_REPLYPORT(a1)
  1244.     move.w    (sp)+,MN_LENGTH(a1)
  1245.  
  1246.     rts
  1247. .err
  1248.     move.l    (sp)+,a0
  1249.     move.w    (sp)+,d1
  1250.  
  1251.     rts
  1252.  
  1253.  
  1254. ******* ExtGfx.s/DeleteStdIO ******************************************
  1255. *
  1256. *   NAME
  1257. *    DeleteStdIO -- 
  1258. *                   return memory allocated for Standard IO Structure.
  1259. *   SYNOPSIS
  1260. *    DeleteStdIO(StdIO)
  1261. *               a0
  1262. *    void DeleteStdIO(struct IORequest *)
  1263. *   FUNCTION
  1264. *    Free the memory allocted for IO request.
  1265. *   INPUTS
  1266. *    A pointer to a standard IO structure.
  1267. *   RESULTS
  1268. *    None.
  1269. *   BUGS
  1270. *    ?
  1271. ******************************************************************************
  1272. *
  1273. *
  1274.  
  1275. ******* ExtGfx.s/DeleteExtIO ******************************************
  1276. *
  1277. *   NAME
  1278. *    DeleteExtIO --
  1279. *                   return memory allocated for extended IO Structure.
  1280. *   SYNOPSIS
  1281. *    DeleteExtIO(ExtIO)
  1282. *             a0
  1283. *    void DeleteExtIO(struct IORequest *)
  1284. *   FUNCTION
  1285. *    Free the memory allocted for IO request.
  1286. *   INPUTS
  1287. *    A pointer to a extended IO structure.
  1288. *   RESULTS
  1289. *    None.
  1290. *   BUGS
  1291. *    ?
  1292. ******************************************************************************
  1293. *
  1294. *
  1295.  
  1296. DeleteStdIO
  1297.  
  1298. DeleteExtIO    ; (IOReq),a0
  1299.  
  1300.     move.b    #-1,LN_TYPE(a0)
  1301.     move.l    #-1,IO_DEVICE(a0)
  1302.     move.l    #-1,IO_UNIT(a0)
  1303.     clr.l    d0
  1304.     move.w    MN_LENGTH(a0),d0
  1305.     move.l    a0,a1
  1306.     CALLEX    FreeMem
  1307.  
  1308.     rts
  1309.  
  1310.  
  1311. ******** DATA STRUCTURES ***********
  1312.  
  1313. dsp_Template
  1314.     dcb.b    LN_SIZE
  1315.     dc.w    3
  1316.     dc.l    MEMF_PUBLIC!MEMF_CLEAR
  1317.     dc.l    v_SIZEOF
  1318.     dc.l    MEMF_PUBLIC!MEMF_CLEAR
  1319.     dc.l    vp_SIZEOF
  1320.     dc.l    MEMF_PUBLIC!MEMF_CLEAR
  1321.     dc.l    ri_SIZEOF
  1322.  
  1323.     end
  1324.